#include <unistd.h>
#include "protocol.h"
#include "clientInfo.h"
#include "clientMusic.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int cSendMusic(const int sendFd, const char *fileName){
	int fileFd=open(fileName, O_RDONLY);
	if(fileFd==-1){
		perror("MusicOpen");
		return -1;
	}
	int cnt=0;
	int writeBytes=0;
	int readBytes;
	struct message msg;
	//음악 전송 시작
	msg.type=0x40;
	msg.length=3;
	sendMessage(sendFd, msg);
	//음악 전송 중
	while(1){
		struct musicMessage mbuf;
		readBytes=0;
		mbuf.musicNo=cnt;
		readBytes=read(fileFd,mbuf.buf,MUSICBLKSIZE);
		if(readBytes<=0)
			break;
		mbuf.length=6+readBytes;
		mbuf.type=0x41;
		mbuf.roomNo=myRoomInfo.roomID;
	//	sendMessage(sendFd,(struct message)(*(void*)&mbuf));
		cnt++;
	}
	//음악 전송 끝
	msg.type=0x42;
	msg.length=3;
	sendMessage(sendFd,msg);
	close(fileFd);
	return 1;
}

void *receiveMusic(void *arg){
	
	
}
